/**
 * A true simple boot code
 *
 * Author: Renê S. Pinto
 * Date: Apr, 2009
 *
 * To compile:
 *        make
 *
 * To test:
 *        make test
 *   OR:
 *
 * Pick up your pendrive, floopy disk, etc:
 *
 *    sudo dd if=myboot.bin of=/dev/XXX
 *
 * PS1> /dev/XXX should point to your device, perhaps
 *      /dev/fd0 or /dev/sdb
 * PS2> BEAWARE: All data in your disk will be lost!
 *
 *    Boot with your disk =:)
 */


/**
 * Address of video memory
 * Each chatacter are represented by 2 bytes:
 *
 * Byte:      First                      Second
 *        -----------|-----------------------------------------
 *       |  8 bits   | 1 bit |  3 bits  |   1 bit   |  3 bits  |
 *       |-----------|-----------------------------------------|
 *       | Character | Blink | BG color | Intensity | FG color |
 *        -----------|-----------------------------------------
 *
 * Fore more information, see:
 * http://www.intelligent-systems.info/classes/ee360/game1234/Video%20memory.htm
 */
#define VIDEO_MEM 0xB8000

.global _start

.text

_start:

.code16

/**
 * Setup correct values to segment registers.
 *
 * This is necessary because some 'bugged' BIOS
 * leave us at 0x7C00:0x0000, not in 0x0000:0x7C00,
 * that is the same place, but with offset 0.
 */
	xor %ax, %ax
	mov %ax, %ds
	mov %ax, %es
	mov %ax, %fs
	mov %ax, %ss

	jmp start

start:
	movb $'A', %al
	movb $0x1E, %ah  /* Yellow char with blue background, high intensity */
	movl $VIDEO_MEM,%ecx
	movw %ax,(%ecx)

loop:
	jmp loop

. = _start + 510

.byte 0x55,0xAA

